Part Number Hot Search : 
74HC02AP A8337 F75384M 1014A SDR622DM 3232T 25320 4140A
Product Description
Full Text Search
 

To Download AN3023 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  october 2009 doc id 16113 rev 1 1/23 AN3023 application note using the analog-to-digital conver ter of the stm8a microcontroller introduction the purpose of this application note is to explain how to use the analog-to-digital converter implemented in the stm8a microcontroller family. the document provides useful information on how to configure the adc registers and microcontroller resources and use the analog-to-digital converter in different modes. the stm8a firmware library, containing source code of all the examples described in this application note, can be downloaded from the stmicroelectronics website: www.st.com. www.st.com
contents AN3023 2/23 doc id 16113 rev 1 contents 1 adc hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1 general properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 adc operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 summary of the features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3 configuring adc registers for conversion . . . . . . . . . . . . . . . . . . . . . . . 9 3.1 adc setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.1 adc clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.2 adc on/off control (power on) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.3 channel selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.4 conversion on external trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.5 conversion modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.2 storing converted values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.3 adc interrupt management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4 practical application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.1 areas of use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.2 hardware connection examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.3 methods for precision improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 5 design recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
AN3023 adc hardware description doc id 16113 rev 1 3/23 1 adc hardware description 1.1 general properties stm8a family microcontrollers include an anal og-to-digital converter which has up to 16 multiplexed inputs. the adc resolution is 10 bits. the number of external analog inputs depends on the package size of the particular stm8a family device. the adc is a successive approximation analog -to-digital converter. conversion can be performed in continuous mode or single mode. the digital result is then stored in registers. because the adc resolution is 10 bits and the adc data register length is 16 bits, the analog-to-digital converter result is stored in two 8-bit registers, and the data is either right or left aligned (this is selectable). the event used to start conversion can be generated by software or by the stm8a microcontroller's internal timer 1 and timer 2 (a) (any type of timer event can be used). the start of a/d conversion can also be triggered by an external pin. the reference voltage for the analog-to-digital converter depends on the package. it comes either from an external source?in this case the reference must be connected to two external pins?or is connected internally to analog power supply pins. the value of this reference voltage is limited to within the range from 2.75 v up to the voltage applied on the v dda input. the measured voltage must be between v ref+ and v ref ? . resolution can be increased by so-called analog zooming?using a smaller reference voltage around the range of values to be measured. if needed, an interrupt can be generated at the end of conversion and if an analog watchdog event occurred. the analog-to-digital converter is driven by a clock derived from the mcu master clock through a programmable divider. this allows you to select the adc clock speed according to your application requirements. a. trigger feature avail able on selected devices
adc hardware description AN3023 4/23 doc id 16113 rev 1 figure 1. adc block diagram 1. refer to stm8a reference manual for adc registers bit description eoc awd ch3 ch2 ch1 ch0 - sp sel2 sp sel1 sp sel0 - - cont adon - ext trig ext sel1 ext sel0 align - scan - dbuf ovr adon synce adon sync - - - - awdg voltage reference low awdg voltage reference high awdg status register channel [7:0] awdg status register channel [15:8] awdg enable register channel [7:0] awdg enable register channel [15:8] interrupt analog-to-digital converter mux tim1 tim2 general purpose ios prescaler /2, /3:  /18 ck_adc f master 4 2 2 2 data buffer data register schmitt trigger enable te[7:0] schmitt trigger enable te[15:8] ain0 ain15 ain1 adc_etr eocie awdie
AN3023 adc hardware description doc id 16113 rev 1 5/23 1.2 adc operation the analog-to-digital converter supports two basic conversion modes: single mode and continuous mode. figure 2 and figure 3 describe single and continuous mode analog-to-digital converter operation. in single conversion mode, the analog-to-digital converter performs only one conversion on the selected channel. figure 2. single conversion mode in continuous conversion mode, the analog-to-digital converter starts another conversion as soon as the previous one is concluded. figure 3. continuous conversion mode as shown in these figures, after adc power on, the analog-to-digital converter needs a stabilization time t stab (equivalent to one conversion time t conv ) before it starts converting accurately. for subsequent conversions there is no stabilization dela y and adon needs to be set only once. conversion time (14 clocks) 1 sync clock 3 clocks sampling time 10 clocks conversion power-on adc adon=1 clk adon eoc t stab start conversion adon=1 or trigger end of conversion software reads adc data software clears eoc bit start conversion adon=1 or trigger adc inactive next conversion conversion time (14 clocks) power-on adc adon=1 clk adon eoc t stab start conversion adon=1 or trigger end of conversion software clears eoc bit next conversion starts immediately next conversion time (14 clocks) software reads adc data
adc hardware description AN3023 6/23 doc id 16113 rev 1 the adc conversion time takes 14 clock cycles. in addition to the basic conversion modes, some packages have extended features for scan mode and buffered continuous mode. figure 4 summarizes all the possible analog-to-digital converter operating modes. figure 4. adc operating modes start stop channel 1 conversion multiple channels scan conversion (buffered) start channel x conversion single channel continuous conversion start channel x conversion single channel continuous and buffered conversion ... channel n conversion start stop channel x conversion single channel single conversion channel x conversion channel x conversion channel x conversion start channel 1 conversion multiple channel continuous and scan conversion (buffered) ... channel n conversion
AN3023 summary of the features doc id 16113 rev 1 7/23 2 summary of the features the stm8a family contains two types of analog-to-digital converter which are named adc and adc2. depending on the device, it may contain both (adc and adc2) or only one (adc). there are two variants of the first analog-to-digital converter adc: 1. with standard features 2. with extended features for scan mode, buffered continuous mode and analog watchdog the second analog-to-digital converter, adc2, contains a features subset of the first adc module. refer to the stm8a datasheet for more information on the available features. table 1. adc and adc2 features on different devices (1) module features parameter 32 kb die based (2) 128 kb die based (2) 256 kb die based (2) adc resolution 10-bit programmable prescaler f master divided by 2 to 18 operating modes single or continuous mode scan and buffered continuous mode ? scan and buffered continuous mode clock speed f adc = 1 to 4 mhz adc input range v ssa = v in = v dda conversion speed min. 3.5 s @ 4 mhz f adc number of input channels up to 10 up to 16 up to 16 triggers timer 1 and external adc_etr pin external adc_etr pin timer 1, timer 2 and external adc_etr pin data format left or right alignment adc interrupt eoc and awd eoc eoc and awd analog watchdog yes ? yes schmitt trigger enable/disable yes yes yes synchronization mechanism between adc and adc2 ??yes analog zooming ? through dedicated vref pins through dedicated vref pins
summary of the features AN3023 8/23 doc id 16113 rev 1 adc2 resolution ? ? 10-bit programmable prescaler ? ? f master divided by 2 to 18 operating modes ? ? single or continuous mode clock speed ? ?f adc = 1 to 4 mhz adc input range ? ?v ssa = v in = v dda conversion speed ? ? min. 3.5 s @ 4 mhz f adc number of input channels ? ?12 triggers ? ? timer1 and timer2 data format ? ? left or right alignment adc interrupt ? ? eoc and awd analog watchdog ? ?yes schmitt trigger enable/disable ? ?yes synchronization mechanism between adc and adc2 ? ?yes analog zooming ? ?? 1. for feature details, refer to the stm8 a reference manual and the device datasheet. 2. die information is stored in chip id registers. refer to the reference manual for further details. table 1. adc and adc2 features on different devices (1) (continued) module features parameter 32 kb die based (2) 128 kb die based (2) 256 kb die based (2)
AN3023 configuring adc registers for conversion doc id 16113 rev 1 9/23 3 configuring adc registers for conversion 3.1 adc setup before starting an adc conversion, adc setup is done using the following steps: adc clock selection (def ine conversion speed) channel selection power on the adc (set adon bit) wait for 14 adc clock cycles (14 * t adc ) conversion mode selection (single or continuous) trigger source selection and only after trigger enable apply trigger source or set adon bit 3.1.1 adc clock the clock supplied to the adc peripheral is the prescaled f master clock. the prescaler is applied on bit spsel[2:0] in the adc_cr1 register and it can be selected from f master /2 to f master /18. the prescaler selection must ensure a maximum 4 mhz adc frequency. adc conversion time depends on the adc clock frequency, the sampling time duration and the adc resolution. the minimum adc conversion time is 3.5 s @ 4 mhz adc clock frequency. note: it is recommended to change bits spsel[2:0] when the adc is in power-down mode. this is because, internally, there may be a glitch in the clock during this change. if this change is made when adc is not in power-down, the user is required to ignore the first converted result. 3.1.2 adc on/off control (power on) the adc can be powered on by setting the adon bit in the adc_cr1 register. when the adon bit is set for the first time, it wakes up the adc from power-down mode. after power on, wait for stabilization time and then, to start a conversion, either set the adon bit again in the adc_cr1 register or use an external trigger source (timers or adc_etr pin). at the end of conversion, the adc remains powe red on and the adon bit has to be set only once to start the next conversion. if the adc is not used for a long time, it is recommended to switch it off to decrease power consumption. this is done by clearing the adon bit. when the adc is powered on, the output stage of the selected channel is disabled; therefore it is recommended to select the channel first before powering on the adc. note: if any bit of the adc_cr1 register other than adon is changed at the same time, the conversion is not triggered. this is to prevent triggering an erroneous conversion. moreover, be aware that any bit manipulation instruction on the adc_cr1 register can start a new conversion due to the fact that the adon bit is read as ?1? and then written back as ?1? by this operation.
configuring adc registers for conversion AN3023 10/23 doc id 16113 rev 1 3.1.3 channel selection there are up to 16 input channels in adc and up to 12 input channels in adc2 (the maximum number of channels per adc peripheral depends on the mcu package size). external input channels can be selected by bits ch[3:0] in the adc_csr register. if the channel is changed during an ongoing conversion, the current conversion is reset and a new start pulse is sent to adc. 3.1.4 conversion on external trigger conversion can also be started by an external trigger event after adc power on. the external trigger source can be a timer (b) trgo event or a rising edge on the external adc_etr (b) pin. bit exttrig is set in the adc_cr 2 register to enable the conversion by external trigger and the bits extsel[1:0] select the trigger source as either the timer or the external trigger pin. the different software sequences (shown below) to select the trigger source and enable the external trigger depend on the adc state (powered-on or powered-off). case 1: adc is in powered-on state adc_cr2 = value1; select the source (extsel[1:0] bits) adc_cr2 |= 0x40; enable external trigger (exttrig bit) case 2: adc is in powered-off state when the adc is in powered-off state, the user is free to choose between the above software sequence, that is, for adc powered-on state or the sequence below: adc_cr2 = value; select the source and enable the external trigger 3.1.5 conversion modes single conversion mode in single conversion mode, the adc performs one conversion on the channel selected by bits ch[3:0] in the adc_csr register. at the end of conversion, the eoc bit is set and the result can be read from the registers adc_drh and adc_drl. the interrupt is generated if the eoc interrupt is enab led in the adc_csr register. example 1 f master = 16 mhz f adc = 4 mhz channel = ain1 single conversion mode, left alignment mode starting adc by software b. refer to the datasheet for the detai ls on the trigger source available.
AN3023 configuring adc registers for conversion doc id 16113 rev 1 11/23 for example 1 , the adc registers should be configured as follows: adc_cr1:spsel[2:0] = 010 f adc = 4 mhz (that is, f master /4) adc_csr:ch[3:0] = 0001 ain1 channel selected adc_cr1:adon = 1 adc power on wait (14/f adc ) stabilization time before starting the conversion adc_cr1:cont = 0 single conversion mode note: do not perform the operation ?adc_cr1:cont = 0 single conversion mode? if the cont bit is already 0 (see note in section 3.1.2 ). adc_cr2:align = 0 left alignment adc_cr1:adon = 1 starting the conversion by software wait (adc_csr:eoc = 1) end of conversion see the result of the conversion in adc data registers adc_drh and adc_drl. continuous conversion mode in continuous conversion mode, the adc starts another conversion as soon as it finishes the last one. a new conversion starts automatically. for this conversion mode, set the cont bit to ?1? in the adc_cr1 register. example 2 f master = 4 mhz f adc = 1 mhz channel = ain2 continuous conversion model, right alignment starting adc by external trigger event on adc_etr pin for example 2 , the adc registers should be configured as follows: adc_cr1:spsel[2:0] = 010 f adc = 1 mhz (that is, f master /4) adc_csr:ch[3:0] = 0010 ain2 channel is selected adc_cr1:adon = 1 adc power on wait (14/f adc ) stabilization time before starting the conversion adc_cr1:cont = 1 continuos conversion mode adc_cr2:align = 1 left alignment adc_cr2:extsel[1:0] = 01 external trigger on adc_etr adc_cr2:exttrig = 1 conversion on external event is enabled rising edge on adc_etr pin wait (adc_csr:eoc = 1) end of conversion if you want to save the result of the current conversion, save the values of data register adc_drh and adc_drl before starting the next conversion.
configuring adc registers for conversion AN3023 12/23 doc id 16113 rev 1 practical use continuous conversion mode is useful for collecting a set of analog values from an external analog signal (for example, to read an ac voltage waveform). single scan mode single scan mode is started by triggering a conversion while the scan bit is set in the adc_cr2 register and the cont bit is 0 in the adc_cr1 register. the scan is performed from channel 0 up to the channel n programmed in bits ch[3:0] in register adc_csr. do not clear the scan bit while the conversion sequence is in progress. single scan mode can be stopped immediately by clearing the adon bit in the adc_cr1 register. example 3 f master = 4 mhz f adc = 1 mhz single scan mode from ain0 to ain5 channel right alignment starting adc by software for example 3 , the adc registers should be configured as follows: adc_cr1:spsel[2:0] = 010 f adc = 1 mhz (that is, f master /4) adc_csr:ch[3:0] = 0101 select the scan from ain0 to ain5 adc_cr1:adon = 1 adc power on wait (14/f adc ) stabilization time before starting the conversion adc_cr2:scan = 1 scan mode enable adc_cr2:align = 1 right alignment adc_cr1:adon = 1 starting the conversion by software wait (adc_csr:eoc = 1) end of conversion read the result of the conversion in adc_dbxrh and adc_dbxrl data buffer registers, where x = 0..5. practical use single scan mode is useful for collecting differen t analog values from external sensors. this conversion mode permits a faster conversion operation than the simple single conversion mode (which requires conversion to be performed channel per channel). continuous scan mode continuous scan mode is started by triggering a conversion while the scan bit is set in the adc_cr2 register and cont bit is set in the adc_cr1 register. the scan is performed from channel 0 up to the channel n programmed in bits ch[3:0], and, when the eoc bit is set, a new scan is started automatically. the data buffer registers must be read before the completion of new scan sequence, otherwise the data buffers are overwritten. do not clear the scan bit while scan conversi on is in progress. continuous scan mode can be stopped immediately by clearing the adon bit in the adc_cr1 register. alternatively, if
AN3023 configuring adc registers for conversion doc id 16113 rev 1 13/23 the cont bit is cleared while conversion is ongoing, conversion stops the next time the last channel has been converted. example 4 f master = 4 mhz f adc = 2 mhz continuous scan from ain0 to ain3 channel right alignment starting adc by tim1 for example 4 , the adc registers should be configured as follows: adc_cr1:spsel[2:0] = 000 f adc = 2 mhz (that is, f master /2) adc_csr:ch[3:0] = 0011 channel from ain0 to ain3 adc_cr1:adon = 1 adc power on wait (14/f adc ) stabilization time before starting the conversion adc_cr1:cont = 1 continuous conversion mode adc_cr2:scan = 1 scan mode enable adc_cr2:align = 1 right alignment adc_cr2:extsel[1:0] = 00 internal tim1 trgo event adc_cr2:exttrig = 1 conversion on external event is enabled timer initialization for trigger output: the timer has to be configured in pwm mode, with a period of at least 7 s, in order to guarantee a good adc conversion. f master = 4 mhz, prescaler = 1, tim1 counter clock = 2 mhz pwm signal @50 khz (period = 20 s) tim1_smcr:msm = 1 tim1 configured as master mode tim1_cr2:mms[6:4] = 100 oc1ref signal is used ad trigger output (trgo) tim1_cr1:cen = 1 timer counter enable adc conversion will start at each ri sing edge event of oc1ref signal wait (adc_csr:eoc = 1) end of conversion read the result of the current conversion from adc_dbxrh and adc_dbxrl registers (x = 0..3) before of the end of next conversion. the ovr flag is set if one of the buffer registers is overwritten . note: 1 in scan mode, do not use the bit manipulation instruction (bres) to clear the eoc flag because it performs a read-modify-write on the whole adc_csr register, reading the current channel number from the ch[3:0] register and writing it back. this changes the last channel number for the scan sequence. the correct way to clear the eoc flag in continuous scan mode is to load a byte in the csr register from a ram variable, clearing the eoc flag and reloading the last channel number for the scan sequence. 2 when using scan mode, it is not possible to use channels ain0 to ainn in output mode because the output stage of each channel is disabled when it is selected by the adc multiplexer.
configuring adc registers for conversion AN3023 14/23 doc id 16113 rev 1 buffered continuous mode the buffered mode is enabled in the continuous conversion mode if bit dbuf = 1 in the adc_cr3 register. the data buffer registers are fille d with the results for up to 16 consecutive conversions performed on a single channel. example 5 f master = 2 mhz f adc = 0.5 mhz buffered continuous mode for channel 3 left alignment starting adc by software for example 5 , the adc registers should be configured as follows: adc_cr1:spsel[2:0] = 010 f adc = 0.5 mhz (that is, f master/ 4) adc_csr:ch[3:0] = 0011 ain3 channel adc_cr1:adon = 1 adc power on wait (14/f adc ) stabilization time before starting the conversion adc_cr1:cont = 1 continuos conversion mode adc_cr3:dbuf = 1 data buffer enable adc_cr2:align = 0 left alignment adc_cr1:adon = 1 starting the conversion of the channel 3 by software wait (adc_csr:eoc = 1) end of conversion the results of the 16 consecutive conversions should be read from on adc_dbxrh and adc_dbxrl registers (x = 0..15) before the end of the next conversions. the ovr flag is set if one of the buffer registers is overwritten. analog watchdog in continuous mode, the analog watchdog is always enabled. the awd analog watchdog flag is set if the analog voltage converted by adc is out of the guard band limited by low and high threshold values. the low and high threshold values are programmed in the adc_htr and adc_ltr registers. figure 5. analog watchdog the adc_htr and adc_ltr values can be calculated by the formula , analog voltage htr ltr high threshold guarded area low threshold adc_xtr v ain v ref+ v ref- ? ----------------------------------------- 2 n 1 ? () ? =
AN3023 configuring adc registers for conversion doc id 16113 rev 1 15/23 where v ain is the higher or lower voltage value of the guarded area and n is the adc resolution. example 6 f master = 4 mhz f adc = 2 mhz channel = ain0 and ain1 continuous scan mode, left alignment analog watchdog: monitoring ain0 within 1.0 v and 4.0 v v ref+ = 5.0v, v ref ? = 0.0 v starting adc by software for example 6 , the adc registers should be configured as follows: adc_cr1:spsel[2:0] = 000 f adc = 2 mhz (that is, f master /2) adc_csr:ch[3:0] = 1100 ain0 to ain12 channels adc_cr1:adon = 1 adc power on wait (14/f adc ) stabilization time before starting the conversion adc_cr1:cont = 1 continuous conversion mode adc_cr2:scan = 1 scan mode enable adc_htrl = 0x03; adc_htrh = 0xcc; adc high threshold is 819 adc_ltrl = 0x01; adc_ltrh = 0x33; adc low threshold is 205 adc_awcrl = 0x01; watchdog enabled on ain0 adc_cr1:adon = 1 starting the conversion by software wait (adc_csr:awd = 1) analog watchdog event has occurred read the result of the conversion in adc_dbxrh and adc_dbxrl data buffer registers, where x = 0..12. if any of the conversion happens out of high and low limit, the awd flag in adc_csr register and the corr esponding bits in the awsr l register will be set to ?1?. depending on whether or not the eoc interrupt, the awd interrupt, or both, are enabled, there could be different combination of managing the analog watchdog. please refer to the stm8a reference manual for details. note: in the buffered continuous mode, the adc1_awcrx register indicates which data buffered has to be monitored.
configuring adc registers for conversion AN3023 16/23 doc id 16113 rev 1 synchronization between two adcs this feature can be applied only if the device contains both adc modules (adc and adc2). the synchronization mechanism can only be used for single conversion and can be triggered either by software or by hardware. to start the synchronous conversion, the adse bit must be set to ?1? in the cr3 registers of both adc and adc2. when the ads bit of the master adc module is set, or another event triggers a conversion on the master adc module, a conversion on the slave module (adc2) is triggered synchronously. example 7 f master = 4 mhz f adc = f adc2 = 2 mhz channels: ain2 on adc and ain1 on adc2 left alignment starting adc and adc2 by software for example 7 , the adc registers should be configured as follows: //adc2 setting - slave adc2_csr:ch[3:0] = 0001 ain1 channel adc2_cr1 adon = 1; adc2 power on wait (14/f adc ) stabilization time before starting the conversion //adc setting - master adc_csr:ch[3:0] = 0010 ain2 channel adc_cr1 adon = 1; adc power on wait (14/f adc ) stabilization time before starting the conversion adc_cr3:adse = 1; //enable sync on adc adc2_cr3:adse = 1; //enable sync on adc2 adc_cr3:ads = 1; //ads start trigger, parallel conversion is started note: before starting synchronization conversion, the two adc modules have to be programmed with the same clock prescaler values. it is recommended to program the prescaler register before switching on the adcs.
AN3023 configuring adc registers for conversion doc id 16113 rev 1 17/23 3.2 storing converted values in the scan mode and buffered continuous mode, the converted adc values are stored in the data buffer registers adc_dbxrh and adc_dbxrl, where x = 1..15. in the normal mode, the converted adc values are stored in the adc data registers adc_drh and adc_drl. adc_drh and adc_drl also contain the last converted value in scan and buffered continuous mode. different data alignment modes (left or right) can be selected depending on the application. if right alignment mode is chosen, the lsb register (adc_drl) must be read before the msb register (adc_drh), otherwise the values of register adc_drh are not updated. if left alignment mode is chosen , the msb register (adc_drh) must be read before the lsb register (adc_drl), otherwise the values of register adc_drl are not updated. this prevents reading data register values from two different conversions. therefore the reading order must be respected. practical use left alignment is useful for fast read access to the conversion result in 8-bit resolution. right alignment is useful for fast read access when measuring low level signals. in cases where the result does not affect the high order bits, you can read only the lsb byte. 3.3 adc interrupt management adc interrupt sources are selectable from one or more of the following events: end of conversion (eoc) in nonbuffered mode?generated after each ad conversion end of conversion (eoc) in buffered mode?generated after data buffer registers are full analog watchdog alert?when converted values reach the high or low threshold values you can enable the adc interrupt to give the main program fast asynchronous event notification at the end of conversion(s). this means the main program does not need to poll the adc conversion status flags but only has to process the adc data results (for example, after storing a set of conversions in a buffer). the reception of the adc converted data values is performed by an interrupt routine in the background. in addition, the analog watchdog interrupt can be used for monitoring a given analog range on the measured channels. register settings: adc_csr: awdie, eocie bits
practical application AN3023 18/23 doc id 16113 rev 1 4 practical application 4.1 areas of use temperature measurement ? process calibration ? device thermal protection ? fan control power supply measurement ? auto save configuration ? battery charging/protection measurement of physical values in other types of applications ? automation?from sensors with analog outputs ? household?for example, automatic lights dimmers, weather stations, thermometers, security sensors ? industry?for example, lights, thermostats, humidity control ? electrical quantity measurements?for example, voltage, current, capacity, resistance 4.2 hardware connection examples figure 6. simple unipolar dc signal measurement figure 7. external preamplifier usage (with high impedance input) stm8a v ref- v ss ainx u in stm8a v ref- v ss ainx u in + - r1 r2
AN3023 practical application doc id 16113 rev 1 19/23 figure 8. differential dc signal measurement with preamplifier figure 9. ac signal (fft) measurement figure 10. analog zooming figure 11. multiple channel measurement stm8a v ref- v ss ainx u in - + r2 r4 r1 r3 stm8a v ref- v ss ainx u in dc filter stm8a v ref- v ss ainx u in = (v ref+ , v ref- ) v ref+ u ref stm8a v ref- v ss ain1 u in0 ain0 ainx u in1 u inx
practical application AN3023 20/23 doc id 16113 rev 1 4.3 methods for precision improvement this section presents some hardware and software methods to minimize errors that can occur in analog-to-d igital conversions. 4.3.1 hardware methods analog zooming (use appropriate v ref voltage and v ref offset) ? selects reference voltage between input signal ranges ? gives full adc range ? minimum voltage per bit white noise added to measured signal ? wobbling of input signal over several bits makes it possible to use averaging (if input signal is very stable) ? white noise gives independence from sampling frequency hardware design considerations ? grounding ? reference voltage filtering ? supply filtering ? preamplifier usage ? frequency independence 4.3.2 software methods averaging samples ? averaging decreases speed but can improve accuracy digital filtering (50/60 hz suppression from dc value) ? proper sampling frequency to be set (trigger from timer1 is useful in this case) ? software post processing to be performed on sampled data (comb filter) fast fourier transform (fft) for ac measurements ? shows harmonic parts in measured signal ? slower due to more computational power requirements calibration of adc?offset, gain, bit weight calibration ? decreases internal adc errors ? internal adc structure must be known
AN3023 design recommendations doc id 16113 rev 1 21/23 5 design recommendations the main design recommendations for using the analog-to-digital converter are listed below. grounding of analog/digital power ? implement star topology v dda , v ssa filtering ? implement rc, lc filtering ? avoid noise from digital power supply v ref selection?offset, value, precision ? reference voltage source precision and stability to co rrespond to the required precision in the applicat ion and the adc?s capability ? reference voltage source value and precision to correspond to the expected measurement range source impedance vs. input impedance knowledge ? use input buffers for measured signal ? impedance relation with required conversion speed external preamplifier usage ? for low (and also high) level signals ? amplifier speed and precision properties ? amplifier dependency on frequency appropriate adc mode, speed and trigger to be selected
revision history AN3023 22/23 doc id 16113 rev 1 6 revision history table 2. document revision history date revision changes 16-oct-2009 1 initial release.
AN3023 doc id 16113 rev 1 23/23 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2009 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN3023

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X